package com.neuedu.controllers;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.neuedu.model.po.Activity;
import com.neuedu.model.po.Candidate;
import com.neuedu.model.service.VoteService;

@Controller
public class HomeController {
	
	@Autowired
	private VoteService voteService;
	
	//restFul请求方式
	@RequestMapping("/activityHome/{aid}")
	public @ResponseBody Activity getActivityById(@PathVariable int aid) throws Exception{
		return voteService.selectActivityById(aid);
	}
	
	/*传统的请求方式
	 * @RequestMapping("/activityHome")
	public @ResponseBody Activity getActivityById(int aid) throws Exception{
		return voteService.selectActivityById(aid);
	}*/
	
	//restFul请求方式
//	@RequestMapping("/candidateHome/{aid}/{pageNum}")
//	public @ResponseBody List<Candidate> getCandidate(@PathVariable int aid,@PathVariable int pageNum){
//		return voteService.selectCandidate(aid, pageNum, 10);
//	}
	
	//传统的请求方式
	@RequestMapping("/candidateHome")
	public @ResponseBody List<Candidate> getCandidate(int aid,int pageNum){
		return voteService.selectCandidate(aid, pageNum, 10);
	}
	
	//传统的请求方式
	@RequestMapping("/candidateHomeByName")
	public @ResponseBody List<Candidate> getCandidateByName(String cname){
		return voteService.selectCandidateByName(cname);
	}
}
